//
//  PuzzseViewController.m
//  PlayDAs
//
//  Created by 周莹 on 15/12/18.
//  Copyright © 2015年 周莹. All rights reserved.
//

#import "PuzzseViewController.h"
// 屏幕_宽_高
#define SCREEN_WIDTH  ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT  ([[UIScreen mainScreen] bounds].size.height)

#define IPHONE6_W 375.0f
#define IPHONE6_H 667.0f

// 控件缩放比例
#define SCALE_WIDTH(w) (SCREEN_WIDTH/375.0*w)

// 如果是iPhone4
#define RECTFIX_WIDTH(a) (IS_IPHONE4 ? a : SCALE_WIDTH(a))
#define RECTFIX_HEIGHT(a) (IS_IPHONE4 ? a : SCALE_HEIGHT(a))

// 左右两边的间距
#define MARGIN_1 20.0f

// lable之间的间距
#define MARGIN_2 14.0f
#define MARGIN_4 10.0f

// 第一个按钮的宽
#define LABLE_1_W 95.0f

// 按钮的高
#define LABLE_H 30.0f

// 按钮的Y值
#define LABLE_Y  18.0f
#define MARGIN_3 10.0f


#define MainTable_1 10.f
#define mainTableH 180.f
#define mainTableY 60.f


#define footButton_1  60.f
//距离底部的距离
#define footButtonLong  80.f


@interface PuzzseViewController ()

@end

@implementation PuzzseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self  cractLable];
    [self  creatTableView];
    [self  craetFootButton];
    [self  creatMidelView];
    
}



-(void)initWithLable1:(NSString *)lable1 lable2:(NSString *)lable2 lable3:(NSString *)lable3{
    self.lable1.text = lable1;
    self.lable2.text = lable2;
    self.lable3.text = lable3;



}

-(void)cractLable{
    
    
    self.scrollView = [[UIScrollView alloc]init];
    
    self.scrollView.contentSize = CGSizeMake(SCREEN_WIDTH,SCREEN_HEIGHT );
    // self.scrollView.backgroundColor = RGBA(238, 239, 242, 1);
    
    self.scrollView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT );
    
    [self.view addSubview:self.scrollView];
    
    
    CGFloat  lableW = SCALE_WIDTH(LABLE_1_W);
    CGFloat  lableH = SCALE_WIDTH(LABLE_H);
    CGFloat  lableX = MARGIN_1;
    CGFloat  lableY = LABLE_Y;
    
    self.lable1 = [[UILabel  alloc] initWithFrame:CGRectMake(lableX, lableY, lableW, lableH)];
    self.lable1.text = @"第 001 轮";
    self.lable1.backgroundColor = [UIColor  peachColor];
    self.lable1.layer.cornerRadius = 10;
    [self.scrollView  addSubview:self.lable1];
    
    
    CGFloat  w = (SCREEN_WIDTH  - (LABLE_Y *2)- (MARGIN_1 * 2)- lableW)/2;
    
    //    CGFloat btn2W = w;
    //    CGFloat btn2H = btn1H;
    //    CGFloat btn2X = CGRectGetMaxX(self.button1.frame) + MARGIN_2;
    //    CGFloat btn2Y = BUTTON_Y;
    
    CGFloat  lable2W = w;
    CGFloat  lable2H = lableH;
    CGFloat  lable2X = CGRectGetMaxX(self.lable1.frame) + MARGIN_2;
    CGFloat  lable2Y = LABLE_Y;
    
    
    self.lable2 = [[UILabel  alloc] initWithFrame:CGRectMake(lable2X, lable2Y, lable2W, lable2H)];
    self.lable2.text = @"第 001 题";
    self.lable2.backgroundColor = [UIColor  peachColor];
    self.lable2.layer.cornerRadius = 10;
    [self.scrollView  addSubview:self.lable2];
    
    
    CGFloat  lable3W = w;
    CGFloat  lable3H = lableH;
    CGFloat  lable3X = CGRectGetMaxX(self.lable2.frame) + MARGIN_2;
    CGFloat  lable3Y = LABLE_Y;
    
    
    self.lable3 = [[UILabel  alloc] initWithFrame:CGRectMake(lable3X, lable3Y, lable3W, lable3H)];
    self.lable3.text = @"第 001 秒";
    self.lable3.backgroundColor = [UIColor  peachColor];
    self.lable3.layer.cornerRadius = 10;
    [self.scrollView  addSubview:self.lable3];
    
    
}

-(void)creatTableView{
    
    
    
//    CGFloat backMaintableViewW = SCREEN_WIDTH-10;
//    CGFloat backMaintableViewH = SCALE_WIDTH(SCREEN_HEIGHT);
//    CGFloat backMaintableViewX = (SCREEN_WIDTH - backMaintableViewW) * 0.5;
//    CGFloat backMaintableViewY = 0;
//    
//    self.BackmainTableView = [[UITableView  alloc] initWithFrame:[UIScreen  mainScreen].bounds];
//    self.backScreenVIew = [[UIView alloc] initWithFrame:CGRectMake(backMaintableViewX, backMaintableViewY, backMaintableViewW, backMaintableViewH)];
//    self.backScreenVIew.backgroundColor = [UIColor  lightGrayColor];
//        [self.view  addSubview:self.BackmainTableView];
//    [self.BackmainTableView  addSubview:self.backScreenVIew];
//    
    
    CGFloat feedW = SCREEN_WIDTH-10;
    CGFloat feedH = SCALE_WIDTH(300);
    CGFloat feedX = (SCREEN_WIDTH - feedW) * 0.5;
    CGFloat feedY = 50;

    self.mainTableView = [[UITableView  alloc] initWithFrame:CGRectMake(feedX, feedY, feedW, feedH)];
    self.backeView = [[UIView  alloc] initWithFrame:CGRectMake(feedX, feedY, feedW, feedH)];
    self.backeView.backgroundColor = [UIColor  yellowColor];
    [self.mainTableView  addSubview:self.backeView];
    [self.scrollView  addSubview:self.mainTableView];

    
    
    
    
    

}



-(void)creatMidelView{

//    CGFloat addrW = SCREEN_WIDTH-10;
//    CGFloat addrH = SCALE_WIDTH(150);
//    CGFloat addrX = (SCREEN_WIDTH - addrW) * 0.5;
//    CGFloat addrY = CGRectGetMaxY(self.mainTableView.frame) + 10;
//
//    self.midView = [[UIView  alloc] initWithFrame:CGRectMake(addrX, addrY, addrW, addrH)];
//    self.midView.backgroundColor = [UIColor  palePurpleColor];
//    [self.view  addSubview:self.midView];
//

    CGFloat TextFieldW = SCREEN_WIDTH-10;
    CGFloat TextFieldH = SCALE_WIDTH(80);
    CGFloat TextFieldX = MARGIN_3;
   // CGFloat TextFieldY = CGRectGetMinY(self.midView.frame) + 20;
   CGFloat TextFieldY = CGRectGetMaxY(self.mainTableView.frame) + 20;
    self.textFieldP = [[UITextField  alloc] initWithFrame:CGRectMake(TextFieldX, TextFieldY, TextFieldW, TextFieldH)];
    self.textFieldP.placeholder = @"公司详情bjbjbjbb公司详情bjbjbjbb公司详情bjbjbjbb公司详情bjbjbjbb公司详情bjbjbjbb公司详情bjbjbjbb公司详情bjbjbjbb公司详情bjbjbjbb";
    [self.scrollView  addSubview:self.textFieldP];
    
    
    
    CGFloat AutherW = SCALE_WIDTH(70);
    CGFloat AutherH = SCALE_WIDTH(30);
    CGFloat AutherX = MARGIN_3;
    CGFloat AutherY = CGRectGetMaxY(self.textFieldP.frame) + 20;
    
    self.authorLable = [[UILabel  alloc] initWithFrame:CGRectMake(AutherX, AutherY, AutherW, AutherH)];
    self.authorLable.backgroundColor = [UIColor  greenColor];
    [self.scrollView  addSubview:self.authorLable];

    
    
    CGFloat AutherNameW = SCALE_WIDTH(70);
    CGFloat AutherNameH = SCALE_WIDTH(30);
    CGFloat AutherNameX = MARGIN_3 + CGRectGetMaxX(self.authorLable.frame);
    CGFloat AutherNameY = CGRectGetMaxY(self.textFieldP.frame) + 20;
    
    self.authorLableName = [[UILabel  alloc] initWithFrame:CGRectMake(AutherNameX, AutherNameY, AutherNameW, AutherNameH)];
    self.authorLableName.backgroundColor = [UIColor  greenColor];
    [self.scrollView  addSubview:self.authorLableName];
    

    CGFloat suremW = SCALE_WIDTH(70);
    CGFloat suremH = SCALE_WIDTH(30);
    CGFloat suremX = MARGIN_3 + CGRectGetMaxX(self.authorLableName.frame) +30;
    CGFloat suremY = CGRectGetMaxY(self.textFieldP.frame) + 20;
    
    self.sureMoneryLable = [[UILabel  alloc] initWithFrame:CGRectMake(suremX, suremY, suremW, suremH)];
    self.sureMoneryLable.backgroundColor = [UIColor  greenColor];
    [self.scrollView  addSubview:self.sureMoneryLable];
    
    
    CGFloat suremSumW = SCALE_WIDTH(90);
    CGFloat suremSumH = SCALE_WIDTH(30);
    CGFloat suremSumX = MARGIN_3 + CGRectGetMaxX(self.sureMoneryLable.frame) ;
    CGFloat suremSumY = CGRectGetMaxY(self.textFieldP.frame) + 20;
    
    self.sureMoneryLableSum = [[UILabel  alloc] initWithFrame:CGRectMake(suremSumX, suremSumY,suremSumW, suremSumH)];
    self.sureMoneryLableSum.backgroundColor = [UIColor  greenColor];
    [self.scrollView  addSubview:self.sureMoneryLableSum];
    
    
    
    
    CGFloat foot1W = SCALE_WIDTH(80);
    CGFloat foot1H = SCALE_WIDTH(45);
    CGFloat foot1X = MARGIN_3;
    CGFloat foot1Y  = CGRectGetMaxY(self.sureMoneryLableSum.frame)+10;
    
    
    // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
    self.footButton1 = [[UIButton  alloc] initWithFrame:CGRectMake(foot1X, foot1Y, foot1W, foot1H)];
    self.footButton1.backgroundColor = [UIColor  paleGreenColor];
    [self.scrollView  addSubview:self.footButton1];
    
    
    
    CGFloat foot2W = SCALE_WIDTH(55);
    CGFloat foot2H = SCALE_WIDTH(45);
    CGFloat foot2X =  CGRectGetMaxX(self.footButton1.frame) + MARGIN_4;
    CGFloat foot2Y  = CGRectGetMaxY(self.sureMoneryLableSum.frame)+10;
    
    // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
    self.footButton2 = [[UIButton  alloc] initWithFrame:CGRectMake(foot2X, foot2Y, foot2W, foot2H)];
    self.footButton2.backgroundColor = [UIColor  paleGreenColor];
    [self.scrollView  addSubview:self.footButton2];
    
    
    
    
    CGFloat foot3W = SCALE_WIDTH(105);
    CGFloat foot3H = SCALE_WIDTH(45);
    CGFloat foot3X =  CGRectGetMaxX(self.footButton2.frame) + MARGIN_4;
    CGFloat foot3Y  = CGRectGetMaxY(self.sureMoneryLableSum.frame)+10;
    
    // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
    self.footButton3 = [[UIButton  alloc] initWithFrame:CGRectMake(foot3X, foot3Y, foot3W, foot3H)];
    self.footButton3.backgroundColor = [UIColor  paleGreenColor];
    [self.scrollView  addSubview:self.footButton3];
    
    
    
    
    CGFloat foot4W = SCALE_WIDTH(90);
    CGFloat foot4H = SCALE_WIDTH(45);
    CGFloat foot4X =  CGRectGetMaxX(self.footButton3.frame) + MARGIN_4;
    CGFloat foot4Y  = CGRectGetMaxY(self.sureMoneryLableSum.frame)+10;
    
    // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
    self.footButton4 = [[UIButton  alloc] initWithFrame:CGRectMake(foot4X, foot4Y, foot4W, foot4H)];
    self.footButton4.backgroundColor = [UIColor  paleGreenColor];
    [self.scrollView  addSubview:self.footButton4];
    


}

-(void)craetFootButton{
    
    
    
    
    
    
    

//    CGFloat foot1W = SCALE_WIDTH(80);
//    CGFloat foot1H = SCALE_WIDTH(45);
//    CGFloat foot1X = MARGIN_3;
//    CGFloat foot1Y  = SCALE_WIDTH(SCREEN_HEIGHT - 250);
//
//    
//   // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
//    self.footButton1 = [[UIButton  alloc] initWithFrame:CGRectMake(foot1X, foot1Y, foot1W, foot1H)];
//    self.footButton1.backgroundColor = [UIColor  paleGreenColor];
//    [self.view  addSubview:self.footButton1];
//    
//    
//    
//    CGFloat foot2W = SCALE_WIDTH(55);
//    CGFloat foot2H = SCALE_WIDTH(45);
//    CGFloat foot2X =  CGRectGetMaxX(self.footButton1.frame) + MARGIN_4;
//    CGFloat foot2Y  = SCALE_WIDTH(SCREEN_HEIGHT - 250);
//    
//    // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
//    self.footButton2 = [[UIButton  alloc] initWithFrame:CGRectMake(foot2X, foot2Y, foot2W, foot2H)];
//    self.footButton2.backgroundColor = [UIColor  paleGreenColor];
//    [self.view  addSubview:self.footButton2];
//    
//    
//    
//    
//    CGFloat foot3W = SCALE_WIDTH(105);
//    CGFloat foot3H = SCALE_WIDTH(45);
//    CGFloat foot3X =  CGRectGetMaxX(self.footButton2.frame) + MARGIN_4;
//    CGFloat foot3Y  = SCALE_WIDTH(SCREEN_HEIGHT - 250);
//    
//    // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
//    self.footButton3 = [[UIButton  alloc] initWithFrame:CGRectMake(foot3X, foot3Y, foot3W, foot3H)];
//    self.footButton3.backgroundColor = [UIColor  paleGreenColor];
//    [self.view  addSubview:self.footButton3];
//
//    
//    
//    
//    CGFloat foot4W = SCALE_WIDTH(90);
//    CGFloat foot4H = SCALE_WIDTH(45);
//    CGFloat foot4X =  CGRectGetMaxX(self.footButton3.frame) + MARGIN_4;
//    CGFloat foot4Y  = SCALE_WIDTH(SCREEN_HEIGHT - 250);
//    
//    // CGFloat foot1Y = CGRectGetMaxY(self.midView.frame) + 300;
//    self.footButton4 = [[UIButton  alloc] initWithFrame:CGRectMake(foot4X, foot4Y, foot4W, foot4H)];
//    self.footButton4.backgroundColor = [UIColor  paleGreenColor];
//    [self.view  addSubview:self.footButton4];
//


}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
